<h3>Historie záznamu</h3>

 <% unless object.blank? %>
  <% unless object.versions.blank? %>
  <table class="table">
    <thead>
      <tr>
        <th class="first"><%= "#{t 'helpers.label.version.action'}" %></th>
        <th><%= "#{t 'helpers.label.version.created_at'}" %></th>
        <th><%= "#{t 'helpers.label.version.user_id'}" %></th>
        <th><%= "#{t 'helpers.label.version.difference'}" %></th>
        <th class="last" colspan="3"></th>
      </tr>
    </thead>
    <tfoot>
      <tr>
        <td colspan="3"></td>
      </tr>
    </tfoot>
    <tbody>
      <% for version in Version.where(:item_id => object.id, :item_type => object.class.name.constantize).order("versions.created_at DESC").limit(20) %>
        <tr>
          <td><%= t version.event %></td>
          <td><%= raw(l version.created_at) %></td>
          <td><%= version.whodunnit %></td>
          <% unless version.object.blank? %>
          <td>
            <% if object.diff(version.reify).blank? %>
              <strong>Žádné</strong>
            <% else %>
              <% diffs = Array.new %>
              <% object.diff(version.reify).each {|diff, values| %>
                <% diffs <<  t("helpers.label.#{object.class.name.downcase}.#{diff.to_s}") %>
              <% } %>
              <%= diffs.to_sentence %>
            <% end %>
          </td>
          <th>
            <%= button_to_delete "Smazat verzi", admin_version_path(version.id) %>
            <%= button_to_detail "Detail", admin_version_path(version.id) %>
            <%= button_to_confirm "Obnovit verzi", revert_version_path(version.id), "POST" %>
          </th>
          <% else %>
          <th>Žádné</th>
          <% end %>
        </tr>
      <% end %>
    </tbody>
  </table>
  <% else %>
    <p>Pro daný záznam nejsou žádné starší verze.</p>
  <% end %>
<% else %>
  <p>Pro daný záznam nejsou žádné starší verze.</p>
<% end %>